//字典
var dictionaryByCode = ROOT_PATH + "/permission/dictionary/queryDictionaryByDictionaryTypeCode.shtml?code=";
var dictionaryByDatas = ROOT_PATH + "/permission/dictionary/queryDictionaryByDatas.shtml";
//学历
var degree_education=CONSTANT.DictionaryTypeDefConstants.DEGREE_EDUCATION;
/**
 * 职称
 */
var user_title=CONSTANT.DictionaryTypeDefConstants.USER_TITLE;
/**
 * 行政级别
 */
var administrativeLevel=CONSTANT.DictionaryTypeDefConstants.ADMINISTRATIVELEVEL;
/**
 * 工种大类
 */
var workBigType=CONSTANT.DictionaryTypeDefConstants.WORKBIGTYPE;
/**
 * 专业大类
 */
var majorBigType=CONSTANT.DictionaryTypeDefConstants.MAJORBIGTYPE;

//初始化启用状态
function initUseSate() {
    var data=[{id:0,text:'未启用'},{id:1,text:'启用'}];
    $('#useState').combobox({
        data:data,
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text',
        panelHeight:'auto'
    });
}
//初始化性别
function initGender() {
    var data=[{id:0,text:'女'},{id:1,text:'男'}];
    $('#gender').combobox({
        data:data,
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text',
        panelHeight:'auto'
    });
}
//初始化结婚
function initMaritalStatus() {
    var data=[{id:0,text:'未婚'},{id:1,text:'已婚'}];
    $('#maritalStatus').combobox({
        data:data,
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text',
        panelHeight:'auto'
    });
}
//初始化学历
function initEducation() {
    $('#education').combobox({
        url:dictionaryByCode+degree_education,
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text'
    });
}

//初始化职称
function initUserTitle() {
    $('#title').combobox({
        url:dictionaryByCode+user_title,
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text'
    });
}
//初始化行政级别
function initAdministrativeLevel() {
    $('#administrativeLevel').combobox({
        url:dictionaryByCode+administrativeLevel,
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text'
    });
}
/**
 * 工种大类
 */
function initWorkBigType() {
    $('#workBigType').combobox({
        url:dictionaryByCode+workBigType,
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text',
        onSelect:function (record) {
            initWorkSmallType(record.code);
        },
        onChange:function () {
            $('#workSmallType').combobox('setValue','');
        }
    });
}
/**
 * 工种小类
 * @param code
 */
function initWorkSmallType(code) {
    $('#workSmallType').combobox({
        url:dictionaryByDatas,
        queryParams:{data1:code},
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text'
    });
}

/**
 * 专业大类
 */
function initMajorBigType() {
    $('#majorBigType').combobox({
        url:dictionaryByCode+majorBigType,
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text',
        onSelect:function (record) {
            initMajorSmallType(record.code);
        },
        onChange:function () {
            $('#majorSmallType').combobox('setValue','');
        }
    });
}
/**
 * 工种小类
 * @param code
 */
function initMajorSmallType(code) {
    $('#majorSmallType').combobox({
        url:dictionaryByDatas,
        queryParams:{data1:code},
        prompt:'请选择',
        editable:false,
        valueField:'id',
        textField:'text'
    });
}
//初始化职位
function initDuty() {
    $('#duty').combobox({
        url: ROOT_PATH + '/permission/departmentDuty/findByParam.shtml',
        valueField: 'id',
        textField: 'name',
        prompt:'请选择',
        editable:false,
        queryParams: {
            flag: true,
            deptId: $(':input[name=deptId]').val()
        }
    });
}
//初始化岗位
function initPost() {
    $('#post_combo').combobox({
        url: ROOT_PATH + '/permission/post/findByDeptId.shtml',
        valueField: 'id',
        textField: 'text',
        prompt:'请选择',
        editable:false,
        queryParams:{
            deptId: $(':input[name=deptId]').val()
        }
    });
}



//重置下拉框
function resetCombobox(id) {

    $(id).combobox({
        editable:false,
        prompt:'请选择',
        data:[],
        url:null
    });
}

